import { ajaxService } from '@/utils/request';
import * as typeObj from './type';

const env = import.meta.env;
let baseURL = env.VITE_PRODUCE_URL;

let baseURL1 = env.VITE_TAOGESHABI_URL;

/**新增工单 */
export function AddWorkOrders(data: {
  workOrderData: typeObj.TworkOrder[];
  orderNumber?: number;
  totality?: number;
  id: number;
}) {
  return ajaxService({
    url: '/produce/workOrder',
    method: 'post',
    data,
    successMsg: '新增成功',
    baseURL,
  });
}
export function GetWorkOrderPage(params: any) {
  return ajaxService({
    url: '/produce/workorder/page',
    method: 'get',
    params,
    baseURL,
  });
}

export function AddProducePlan(data: any) {
  return ajaxService({
    url: '/produce/plan',
    method: 'post',
    data,
    successMsg: '新增成功',
    baseURL,
  });
}
export function EditProducePlan(data: any) {
  return ajaxService({
    url: '/produce/plan',
    method: 'put',
    data,
    successMsg: '修改成功',
    baseURL,
  });
}
export function GetProducePlanPage(params: any) {
  return ajaxService({
    url: '/produce/plan/page',
    method: 'get',
    params,
    baseURL,
  });
}

export function GetAllProduct(params: any) {
  return ajaxService({
    url: '/factory/product/data',
    method: 'get',
    params,
    baseURL: baseURL1,
  });
}

export function AddPlanWorkShops(data: any) {
  return ajaxService({
    url: '/produce/workshop',
    method: 'post',
    data,
    successMsg: '新增成功',
    baseURL,
  });
}

export function GwtPlanWorkShopPage(params: any) {
  return ajaxService({
    url: '/produce/workshop/page',
    method: 'get',
    params,
    baseURL,
  });
}
// 新增生产领料页面详情
export function GetProducePickAll(params: any) {
  return ajaxService({
    url: '/produce/pick/getAll',
    method: 'get',
    params,
    baseURL,
  });
}

// 生产领料领料页面详情
export function GetProducePlanDetail(params: any) {
  return ajaxService({
    url: '/produce/plan/produce/detail',
    method: 'get',
    params,
    baseURL,
  });
}

/**新建排程 */
export function AddProduceScheduling(data: any) {
  return ajaxService({
    url: '/produce/scheduling',
    method: 'post',
    successMsg: '添加成功',
    data,
    baseURL,
  });
}
/**排程分页 */
export function GetProduceSchedulingPage(params: any) {
  return ajaxService({
    url: '/produce/scheduling/page',
    method: 'get',
    params,
    baseURL,
  });
}

export function GetWorkshopByLine(ids: any[]) {
  return ajaxService({
    url: '/product/line/data',
    method: 'post',
    data: { id: ids },
    baseURL,
  });
}
